package com.fzhucc.utils

import cn.hutool.core.util.RandomUtil
import org.junit.jupiter.api.Test

import org.slf4j.LoggerFactory

/**
 * @author Woolsen
 * @since 2022/12/6 15:10
 */
class WxUtilsTest {

    private val appId = "wx2d9f92cf7ca6552d"
    private val appSecret = "d5e4bdea18ba36bd875b24b08242535e"

    companion object {
        private val log = LoggerFactory.getLogger(WxUtilsTest::class.java)
    }

    @Test
    fun getWechatQr() {
        var qrcode = WxUtils.generateMpQr(appId, appSecret, null, "type=bind&code=${RandomUtil.randomString(10)}", "release")
        log.info("release qrcode: $qrcode")
        qrcode = WxUtils.generateMpQr(appId, appSecret, null, "type=bind&code=${RandomUtil.randomString(10)}", "develop")
        log.info("develop qrcode: $qrcode")
        qrcode = WxUtils.generateMpQr(appId, appSecret, null, "type=bind&code=${RandomUtil.randomString(10)}", "trail")
        log.info("trail qrcode: $qrcode")

    }

    @Test
    fun generateScheme() {
        val scheme = WxUtils.generateScheme(appId, appSecret, "", "", 24 * 60 * 60 * 1000)
        log.info("scheme: $scheme")
    }

    @Test
    fun generateUrlLink() {
        val urlLink = WxUtils.generateUrlLink(
            appId = appId,
            appSecret = appSecret,
            path = "/",
            query = null,
            expireInMill = 24 * 60 * 60 * 1000
        )
        log.info("urlLink: $urlLink")
    }
}